<?php
namespace app\index\controller;

use think\Controller;
use think\Db;
use think\Request;
use think\Session;


class Index extends Controller
{
    // 首页
    public function index()
    {
        // 获取session
    	$session = Session::get();

        // 一级分类
        $category = DB::name('category')->where('pid','0,')->paginate(4);


        // 获取图片
        $picture = DB::table(['picture' => 'p','dt_user' => 'u'])
                    ->field('p.id,p.cate_id,p.title,p.src,u.icon,u.name,p.user_id')
                    ->where('u.id = p.user_id && p.status = 2')
                    ->order('upload_time')
                    ->select();


        // 返回
        return view('index@index/index',[
            'session'   => $session,
            'category'  => $category,
            'picture'   => $picture,
        ]);
    }


    
       

    }









    





